<?php
require_once 'ActionFramework/inputs.php';

class MultiChoiceInputTestCase extends PHPUnit_Framework_TestCase
{
    public function testIndexed()
    {
    	$input = new MultiChoiceInput('DUMMY_NAME', 'Dummy name', array('a', 'b'), true);
    	
    	$result = $input->validate('0');
    	$this->assertTrue($result['valid']);
    	
    	$result = $input->validate('');
    	$this->assertFalse($result['valid']);
    	
    	$result = $input->validate('2');
    	$this->assertFalse($result['valid']);
    }
    
    public function testAssociated()
    {
    	$input = new MultiChoiceInput('DUMMY_NAME', 'Dummy name', array('a'=>'AAA', 'b'=>'BBB'));
    	
    	$result = $input->validate('a');
    	$this->assertTrue($result['valid']);
    	
    	$result = $input->validate('');
    	$this->assertFalse($result['valid']);
    	
    	$result = $input->validate('BBB');
    	$this->assertFalse($result['valid']);
    }
    
    public function testAssociated_Nummeric()
    {
    	$input = new MultiChoiceInput('DUMMY_NAME', 'Dummy name', array(10=>'a', 80=>'b'));
    	
    	$result = $input->validate('10');
    	$this->assertTrue($result['valid']);
    	
    	$result = $input->validate('');
    	$this->assertFalse($result['valid']);
    	
    	$result = $input->validate('c');
    	$this->assertFalse($result['valid']);
    	
    	$result = $input->validate('50');
    	$this->assertFalse($result['valid']);
    }
    
}